﻿namespace QLBanHang.UC
{
    using ConfigDatabase.Class;
    using DevExpress.Data;
    using DevExpress.Utils;
    using DevExpress.XtraEditors;
    using DevExpress.XtraEditors.Repository;
    using DevExpress.XtraGrid;
    using DevExpress.XtraGrid.Columns;
    using DevExpress.XtraGrid.Views.Base;
    using DevExpress.XtraGrid.Views.Grid;
    using DevExpress.XtraTab;
    using Access;
    using BaseClass.Duoc;
    using Report;
    using System;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Windows.Forms;

    public class ucd_dmnhacungcap : XtraUserControl
    {
        private ConnectDatabase _condata;
        private dtoDDMNhaCungCap _dto;
        private General _xuli;
        private SimpleButton btnboqua;
        private SimpleButton btnimport;
        private SimpleButton btnin;
        private SimpleButton btnketthuc;
        private SimpleButton btnluu;
        private SimpleButton btnmoi;
        private SimpleButton btnsua;
        private SimpleButton btnxoa;
        private IContainer components;
        private GridControl gridds;
        private GridColumn gridds_daidien;
        private GridColumn gridds_diachi;
        private GridColumn gridds_dienthoai;
        private GridColumn gridds_id;
        private GridColumn gridds_ma;
        private GridColumn gridds_masothue;
        private GridColumn gridds_nganhang;
        private GridColumn gridds_sotk;
        private GridColumn gridds_stt;
        private GridColumn gridds_ten;
        private GridView gridView1;
        private Label label1;
        private Label label10;
        private Label label2;
        private Label label3;
        private Label label4;
        private Label label5;
        private Label label6;
        private Label label7;
        private Label label8;
        private Label label9;
        private RepositoryItemTextEdit repositoryItemTextEdit1;
        private TextEdit txtdiachi;
        private TextEdit txtdienthoai;
        private TextEdit txtma;
        private TextEdit txtmasothue;
        private TextEdit txtnganhang;
        private TextEdit txtnguoidaidien;
        private TextEdit txtsotk;
        private TextEdit txtstt;
        private TextEdit txtten;

        public ucd_dmnhacungcap()
        {
            this.components = null;
            this.InitializeComponent();
            this._condata = new ConnectDatabase();
        }

        public ucd_dmnhacungcap(ConnectDatabase condata)
        {
            this.components = null;
            this.InitializeComponent();
            this._condata = condata;
        }

        private void btnboqua_Click(object sender, EventArgs e)
        {
            this.f_Control_enable(false);
        }

        private void btnimport_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog {
                Title = "Chọn file excel dữ liệu",
                Filter = "(Excel 2003).xls|*.xls|(Execel 2007).xlsx|*.xlsx",
                FilterIndex = 0,
                Multiselect = false
            };
            dialog.ShowDialog();
            if (dialog.FileName != "")
            {
                string fileName = dialog.FileName;
                DataTable table = this._xuli.f_getdata_fromfileExcel(fileName, "Sheet");
                if (table.Columns.Count != 9)
                {
                    MessageBox.Show("Định dạng file excel kh\x00f4ng đ\x00fang.\nVui l\x00f2ng kiểm tra lại:\n1.Số thứ tự.\n2.M\x00e3 số\n3.T\x00ean nh\x00e0 cung cấp.\n4.Địa chỉ.\n5.Điện thoại.\n6.Người đại diện.\n7.M\x00e3 số thuế.\n8.Số t\x00e0i khoản.\n9.Ng\x00e2n h\x00e0ng.", "Th\x00f4ng b\x00e1o");
                }
                else if ((table.Rows.Count <= 0) || (MessageBox.Show("Bạn c\x00f3 muốn th\x00eam dữ liệu từ file excel v\x00e0o dữ liệu hiện tại kh\x00f4ng?\nChọn Yes để chấp nhận.\nChọn No để bỏ qua thao t\x00e1c.", "Th\x00f4ng b\x00e1o", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.No))
                {
                    dtoDDMNhaCungCap cap = new dtoDDMNhaCungCap(this._xuli.pConFigData);
                    if ((MessageBox.Show("Bạn c\x00f3 muốn hủy dữ liệu hiện tại kh\x00f4ng?\nChọn Yes để chấp nhận.\nChọn No để bỏ qua thao t\x00e1c.", "Th\x00f4ng b\x00e1o", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) && !cap.Delete())
                    {
                        MessageBox.Show("Hủy dữ liệu kh\x00f4ng th\x00e0nh c\x00f4ng.", "Th\x00f4ng b\x00e1o");
                    }
                    else
                    {
                        string str2 = "";
                        for (int i = 0; i < table.Rows.Count; i++)
                        {
                            if (table.Rows[i][table.Columns.Count - 1].ToString() != "")
                            {
                                cap = new dtoDDMNhaCungCap(this._xuli.pConFigData) {
                                    pID = cap.GetIDInsert()
                                };
                                try
                                {
                                    cap.pSTT = int.Parse(table.Rows[i][0].ToString());
                                }
                                catch
                                {
                                }
                                cap.pMA = table.Rows[i][1].ToString();
                                cap.pTEN = table.Rows[i][2].ToString();
                                cap.pDIACHI = table.Rows[i][3].ToString();
                                cap.pDIENTHOAI = table.Rows[i][4].ToString();
                                cap.pDAIDIEN = table.Rows[i][5].ToString();
                                cap.pMASOTHUE = table.Rows[i][6].ToString();
                                cap.pSOTK = table.Rows[i][7].ToString();
                                cap.pNGANHANG = table.Rows[i][8].ToString();
                                if (!cap.Insert())
                                {
                                    object obj2 = str2;
                                    str2 = string.Concat(new object[] { obj2, "\n", cap.pSTT, "-", cap.pMA, "-", cap.pTEN, ";" });
                                }
                            }
                        }
                        if (str2 != "")
                        {
                            MessageBox.Show("C\x00e1c dữ liệu sau bị lỗi:" + str2, "Th\x00f4ng b\x00e1o");
                        }
                        this.f_Loaddata_dmvp();
                    }
                }
            }
        }

        private void btnin_Click(object sender, EventArgs e)
        {
            DataTable dataSource = (DataTable) this.gridds.DataSource;
            dataSource.AcceptChanges();
            DataSet data = new DataSet();
            data.Tables.Add(dataSource.Copy());
            data.WriteXml(Environment.CurrentDirectory + @"\dataxml\d_dmnhacungcap.xml", XmlWriteMode.WriteSchema);
            new XtraReport1().f_load(data, "repx_d_dmnhacungcap.repx");
        }

        private void btnketthuc_Click(object sender, EventArgs e)
        {
            try
            {
                XtraTabPage parent = (XtraTabPage) base.Parent;
                XtraTabControl control = (XtraTabControl) parent.Parent;
                control.TabPages.Remove(parent);
            }
            catch
            {
            }
        }

        private void btnluu_Click(object sender, EventArgs e)
        {
            this._dto = new dtoDDMNhaCungCap(this._condata);
            this._dto.pDAIDIEN = this.txtnguoidaidien.Text;
            this._dto.pDIACHI = this.txtdiachi.Text;
            this._dto.pMA = this.txtma.Text;
            this._dto.pTEN = this.txtten.Text;
            try
            {
                this._dto.pSTT = int.Parse(this.txtstt.Text);
            }
            catch
            {
            }
            this._dto.pDIENTHOAI = this.txtdienthoai.Text;
            this._dto.pMASOTHUE = this.txtmasothue.Text;
            this._dto.pNGANHANG = this.txtnganhang.Text;
            this._dto.pSOTK = this.txtsotk.Text;
            this._dto.pID = int.Parse(this.txtma.Tag.ToString());
            if (this.txtma.Tag.ToString() == "0")
            {
                this._dto.pID = this._dto.GetIDInsert();
                if (!this._dto.Insert())
                {
                    MessageBox.Show("Kh\x00f4ng lưu được th\x00f4ng tin sản phẩm", "Th\x00f4ng b\x00e1o");
                    return;
                }
            }
            else if (!this._dto.Update())
            {
                MessageBox.Show("Kh\x00f4ng lưu được th\x00f4ng tin sản phẩm", "Th\x00f4ng b\x00e1o");
                return;
            }
            this.f_Loaddata_dmvp();
            this.f_Control_enable(false);
        }

        private void btnmoi_Click(object sender, EventArgs e)
        {
            this.f_Loadcontrol_dmvp(0L, "", "", "", "", "", "", "", "", "0");
            this.f_Control_enable(true);
            base.ActiveControl = this.txtma;
        }

        private void btnsua_Click(object sender, EventArgs e)
        {
            this.f_Control_enable(true);
            this.txtten.Focus();
        }

        private void btnxoa_Click(object sender, EventArgs e)
        {
            if ((this.txtma.Tag.ToString() != "0") && (MessageBox.Show("Bạn c\x00f3 chắc chắn muốn hủy th\x00f4ng tin:\n" + this.txtma.Text + " - " + this.txtten.Text + " ?", "Th\x00f4ng b\x00e1o", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) != DialogResult.No))
            {
                try
                {
                    this._dto = new dtoDDMNhaCungCap(this._condata);
                    this._dto.pID = int.Parse(this.txtma.Tag.ToString());
                    if (!this._dto.Delete())
                    {
                        MessageBox.Show("Hủy kh\x00f4ng th\x00e0nh c\x00f4ng.Vui l\x00f2ng kiểm tra lại.", "Th\x00f4ng b\x00e1o");
                    }
                    else
                    {
                        MessageBox.Show("Đ\x00e3 hủy th\x00e0nh c\x00f4ng.", "Th\x00f4ng b\x00e1o");
                        this.f_Loaddata_dmvp();
                    }
                }
                catch
                {
                }
            }
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void f_Control_enable(bool chophep)
        {
            this.btnluu.Enabled = this.btnboqua.Enabled = chophep;
            this.btnmoi.Enabled = this.btnxoa.Enabled = this.btnsua.Enabled = this.btnketthuc.Enabled = !chophep;
            this.gridds.Enabled = !chophep;
        }

        private void f_Loadcontrol_dmvp(long id, string ma, string ten, string masothue, string nguoidaidien, string diachi, string dienthoai, string sotk, string nganhang, string stt)
        {
            this.txtma.Text = ma;
            this.txtma.Tag = id.ToString();
            this.txtten.Text = ten;
            this.txtmasothue.Text = masothue;
            this.txtstt.Text = stt;
            this.txtnguoidaidien.Text = nguoidaidien;
            this.txtdiachi.Text = diachi;
            this.txtdienthoai.Text = dienthoai;
            this.txtnganhang.Text = nganhang;
            this.txtsotk.Text = sotk;
        }

        private void f_Loaddata_dmvp()
        {
            try
            {
                this.gridds.DataSource = this._dto.LoadAll();
            }
            catch
            {
            }
        }

        private void f_loadinfo_dmsanpham(int indexrow)
        {
            try
            {
                this.f_Loadcontrol_dmvp(long.Parse(this.gridView1.GetRowCellValue(indexrow, this.gridds_id).ToString()), this.gridView1.GetRowCellValue(indexrow, this.gridds_ma).ToString(), this.gridView1.GetRowCellValue(indexrow, this.gridds_ten).ToString(), this.gridView1.GetRowCellValue(indexrow, this.gridds_masothue).ToString(), this.gridView1.GetRowCellValue(indexrow, this.gridds_daidien).ToString(), this.gridView1.GetRowCellValue(indexrow, this.gridds_diachi).ToString(), this.gridView1.GetRowCellValue(indexrow, this.gridds_dienthoai).ToString(), this.gridView1.GetRowCellValue(indexrow, this.gridds_sotk).ToString(), this.gridView1.GetRowCellValue(indexrow, this.gridds_nganhang).ToString(), this.gridView1.GetRowCellValue(indexrow, this.gridds_stt).ToString());
            }
            catch
            {
            }
        }

        private void gridView1_CustomSummaryCalculate(object sender, CustomSummaryEventArgs e)
        {
        }

        private void gridView1_FocusedRowChanged(object sender, FocusedRowChangedEventArgs e)
        {
            int indexrow = 0;
            try
            {
                if (this.gridView1.IsFocusedView)
                {
                    indexrow = this.gridView1.GetSelectedRows()[0];
                    this.f_loadinfo_dmsanpham(indexrow);
                }
            }
            catch
            {
            }
        }

        private void InitializeComponent()
        {
            ComponentResourceManager manager = new ComponentResourceManager(typeof(ucd_dmnhacungcap));
            this.label1 = new Label();
            this.label2 = new Label();
            this.txtma = new TextEdit();
            this.label3 = new Label();
            this.txtten = new TextEdit();
            this.label4 = new Label();
            this.txtmasothue = new TextEdit();
            this.label5 = new Label();
            this.txtstt = new TextEdit();
            this.label7 = new Label();
            this.txtnguoidaidien = new TextEdit();
            this.btnmoi = new SimpleButton();
            this.btnluu = new SimpleButton();
            this.btnsua = new SimpleButton();
            this.btnxoa = new SimpleButton();
            this.btnketthuc = new SimpleButton();
            this.gridView1 = new GridView();
            this.gridds_ma = new GridColumn();
            this.repositoryItemTextEdit1 = new RepositoryItemTextEdit();
            this.gridds_ten = new GridColumn();
            this.gridds_diachi = new GridColumn();
            this.gridds_id = new GridColumn();
            this.gridds_stt = new GridColumn();
            this.gridds_dienthoai = new GridColumn();
            this.gridds_sotk = new GridColumn();
            this.gridds_masothue = new GridColumn();
            this.gridds_nganhang = new GridColumn();
            this.gridds_daidien = new GridColumn();
            this.gridds = new GridControl();
            this.btnboqua = new SimpleButton();
            this.btnin = new SimpleButton();
            this.btnimport = new SimpleButton();
            this.label6 = new Label();
            this.txtdiachi = new TextEdit();
            this.label8 = new Label();
            this.txtdienthoai = new TextEdit();
            this.label9 = new Label();
            this.txtnganhang = new TextEdit();
            this.label10 = new Label();
            this.txtsotk = new TextEdit();
            this.txtma.Properties.BeginInit();
            this.txtten.Properties.BeginInit();
            this.txtmasothue.Properties.BeginInit();
            this.txtstt.Properties.BeginInit();
            this.txtnguoidaidien.Properties.BeginInit();
            this.gridView1.BeginInit();
            this.repositoryItemTextEdit1.BeginInit();
            this.gridds.BeginInit();
            this.txtdiachi.Properties.BeginInit();
            this.txtdienthoai.Properties.BeginInit();
            this.txtnganhang.Properties.BeginInit();
            this.txtsotk.Properties.BeginInit();
            base.SuspendLayout();
            this.label1.BackColor = Color.ForestGreen;
            this.label1.Dock = DockStyle.Top;
            this.label1.Font = new Font("Tahoma", 16f);
            this.label1.ForeColor = Color.Yellow;
            this.label1.Location = new Point(0, 0);
            this.label1.Name = "label1";
            this.label1.Size = new Size(0x400, 0x30);
            this.label1.TabIndex = 1;
            this.label1.Text = "DANH MỤC NH\x00c0 CUNG CẤP";
            this.label1.TextAlign = ContentAlignment.MiddleCenter;
            this.label2.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            this.label2.Font = new Font("Tahoma", 10f);
            this.label2.Location = new Point(0x11, 0x12e);
            this.label2.Name = "label2";
            this.label2.Size = new Size(0x57, 0x13);
            this.label2.TabIndex = 2;
            this.label2.Text = "M\x00e3 số:";
            this.label2.TextAlign = ContentAlignment.TopRight;
            this.txtma.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            this.txtma.Location = new Point(0x65, 0x12d);
            this.txtma.Name = "txtma";
            this.txtma.Properties.CharacterCasing = CharacterCasing.Upper;
            this.txtma.Size = new Size(0x90, 20);
            this.txtma.TabIndex = 0;
            this.txtma.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            this.label3.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            this.label3.Font = new Font("Tahoma", 10f);
            this.label3.Location = new Point(0xfb, 0x12e);
            this.label3.Name = "label3";
            this.label3.Size = new Size(0x54, 0x13);
            this.label3.TabIndex = 2;
            this.label3.Text = "T\x00ean:";
            this.label3.TextAlign = ContentAlignment.TopRight;
            this.txtten.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom;
            this.txtten.Location = new Point(0x14c, 0x12d);
            this.txtten.Name = "txtten";
            this.txtten.Size = new Size(0x1de, 20);
            this.txtten.TabIndex = 1;
            this.txtten.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            this.txtten.Validated += new EventHandler(this.txtten_Validated);
            this.label4.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            this.label4.Font = new Font("Tahoma", 10f);
            this.label4.Location = new Point(0, 0x148);
            this.label4.Name = "label4";
            this.label4.Size = new Size(0x68, 0x13);
            this.label4.TabIndex = 2;
            this.label4.Text = "Người đại diện:";
            this.label4.TextAlign = ContentAlignment.TopRight;
            this.txtmasothue.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
            this.txtmasothue.Location = new Point(0x387, 0x12d);
            this.txtmasothue.Name = "txtmasothue";
            this.txtmasothue.Size = new Size(0x73, 20);
            this.txtmasothue.TabIndex = 2;
            this.txtmasothue.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            this.label5.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            this.label5.Font = new Font("Tahoma", 10f);
            this.label5.Location = new Point(3, 0x164);
            this.label5.Name = "label5";
            this.label5.Size = new Size(0x68, 0x13);
            this.label5.TabIndex = 2;
            this.label5.Text = "Số t\x00e0i khoản:";
            this.label5.TextAlign = ContentAlignment.TopRight;
            this.txtstt.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
            this.txtstt.Location = new Point(0x387, 0x161);
            this.txtstt.Name = "txtstt";
            this.txtstt.Size = new Size(0x73, 20);
            this.txtstt.TabIndex = 8;
            this.txtstt.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            this.label7.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
            this.label7.Font = new Font("Tahoma", 10f);
            this.label7.Location = new Point(0x326, 0x12e);
            this.label7.Name = "label7";
            this.label7.Size = new Size(0x60, 0x13);
            this.label7.TabIndex = 2;
            this.label7.Text = "M\x00e3 số thuế:";
            this.label7.TextAlign = ContentAlignment.TopRight;
            this.txtnguoidaidien.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            this.txtnguoidaidien.Location = new Point(0x65, 0x147);
            this.txtnguoidaidien.Name = "txtnguoidaidien";
            this.txtnguoidaidien.Size = new Size(0x90, 20);
            this.txtnguoidaidien.TabIndex = 3;
            this.txtnguoidaidien.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            this.btnmoi.Anchor = AnchorStyles.Bottom;
            this.btnmoi.Appearance.Options.UseTextOptions = true;
            this.btnmoi.Appearance.TextOptions.HAlignment = HorzAlignment.Near;
            this.btnmoi.Image = Resources.Reso.imgnew;// (Image)manager.GetObject("btnmoi.Image");
            this.btnmoi.Location = new Point(0x99, 0x185);
            this.btnmoi.Name = "btnmoi";
            this.btnmoi.Size = new Size(0x4b, 0x17);
            this.btnmoi.TabIndex = 10;
            this.btnmoi.Text = " &Mới [F2]";
            this.btnmoi.Click += new EventHandler(this.btnmoi_Click);
            this.btnluu.Anchor = AnchorStyles.Bottom;
            this.btnluu.Appearance.Options.UseTextOptions = true;
            this.btnluu.Appearance.TextOptions.HAlignment = HorzAlignment.Near;
            this.btnluu.Image = Resources.Reso.imgsave;// (Image)manager.GetObject("btnluu.Image");
            this.btnluu.Location = new Point(0xe7, 0x185);
            this.btnluu.Name = "btnluu";
            this.btnluu.Size = new Size(0x4b, 0x17);
            this.btnluu.TabIndex = 9;
            this.btnluu.Text = " &Lưu [F5]";
            this.btnluu.Click += new EventHandler(this.btnluu_Click);
            this.btnsua.Anchor = AnchorStyles.Bottom;
            this.btnsua.Appearance.Options.UseTextOptions = true;
            this.btnsua.Appearance.TextOptions.HAlignment = HorzAlignment.Near;
            this.btnsua.Image = Resources.Reso.imgedit;// (Image)manager.GetObject("btnsua.Image");
            this.btnsua.Location = new Point(0x135, 0x185);
            this.btnsua.Name = "btnsua";
            this.btnsua.Size = new Size(0x4b, 0x17);
            this.btnsua.TabIndex = 11;
            this.btnsua.Text = " &Sửa [F3]";
            this.btnsua.Click += new EventHandler(this.btnsua_Click);
            this.btnxoa.Anchor = AnchorStyles.Bottom;
            this.btnxoa.Image = Resources.Reso.imgdelete;// (Image)manager.GetObject("btnxoa.Image");
            this.btnxoa.Location = new Point(0x1dc, 0x185);
            this.btnxoa.Name = "btnxoa";
            this.btnxoa.Size = new Size(0x4b, 0x17);
            this.btnxoa.TabIndex = 13;
            this.btnxoa.Text = " &Hủy [F7]";
            this.btnxoa.Click += new EventHandler(this.btnxoa_Click);
            this.btnketthuc.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
            this.btnketthuc.Appearance.Options.UseTextOptions = true;
            this.btnketthuc.Appearance.TextOptions.HAlignment = HorzAlignment.Near;
            this.btnketthuc.Image = Resources.Reso.imgclose;// (Image)manager.GetObject("btnketthuc.Image");
            this.btnketthuc.Location = new Point(0x395, 0x188);
            this.btnketthuc.Name = "btnketthuc";
            this.btnketthuc.Size = new Size(0x65, 0x17);
            this.btnketthuc.TabIndex = 0x10;
            this.btnketthuc.Text = " &Kết th\x00fac [F12]";
            this.btnketthuc.Click += new EventHandler(this.btnketthuc_Click);
            this.gridView1.Appearance.ColumnFilterButton.BackColor = Color.FromArgb(0xca, 0xdd, 0xd0);
            this.gridView1.Appearance.ColumnFilterButton.BorderColor = Color.FromArgb(0xca, 0xdd, 0xd0);
            this.gridView1.Appearance.ColumnFilterButton.ForeColor = Color.Black;
            this.gridView1.Appearance.ColumnFilterButton.Options.UseBackColor = true;
            this.gridView1.Appearance.ColumnFilterButton.Options.UseBorderColor = true;
            this.gridView1.Appearance.ColumnFilterButton.Options.UseForeColor = true;
            this.gridView1.Appearance.ColumnFilterButtonActive.BackColor = Color.FromArgb(0xd3, 0xe2, 0xd8);
            this.gridView1.Appearance.ColumnFilterButtonActive.BorderColor = Color.FromArgb(0xd3, 0xe2, 0xd8);
            this.gridView1.Appearance.ColumnFilterButtonActive.ForeColor = Color.Black;
            this.gridView1.Appearance.ColumnFilterButtonActive.Options.UseBackColor = true;
            this.gridView1.Appearance.ColumnFilterButtonActive.Options.UseBorderColor = true;
            this.gridView1.Appearance.ColumnFilterButtonActive.Options.UseForeColor = true;
            this.gridView1.Appearance.Empty.BackColor = Color.FromArgb(0xf2, 0xf4, 0xec);
            this.gridView1.Appearance.Empty.BackColor2 = Color.White;
            this.gridView1.Appearance.Empty.Options.UseBackColor = true;
            this.gridView1.Appearance.EvenRow.BackColor = Color.FromArgb(0xdd, 0xe3, 0xf5);
            this.gridView1.Appearance.EvenRow.BorderColor = Color.FromArgb(0xdd, 0xe3, 0xf5);
            this.gridView1.Appearance.EvenRow.ForeColor = Color.Black;
            this.gridView1.Appearance.EvenRow.Options.UseBackColor = true;
            this.gridView1.Appearance.EvenRow.Options.UseBorderColor = true;
            this.gridView1.Appearance.EvenRow.Options.UseForeColor = true;
            this.gridView1.Appearance.FilterCloseButton.BackColor = Color.FromArgb(0xca, 0xdd, 0xd0);
            this.gridView1.Appearance.FilterCloseButton.BorderColor = Color.FromArgb(0xca, 0xdd, 0xd0);
            this.gridView1.Appearance.FilterCloseButton.ForeColor = Color.Black;
            this.gridView1.Appearance.FilterCloseButton.Options.UseBackColor = true;
            this.gridView1.Appearance.FilterCloseButton.Options.UseBorderColor = true;
            this.gridView1.Appearance.FilterCloseButton.Options.UseForeColor = true;
            this.gridView1.Appearance.FilterPanel.BackColor = Color.FromArgb(0xf2, 0xf4, 0xec);
            this.gridView1.Appearance.FilterPanel.BackColor2 = Color.White;
            this.gridView1.Appearance.FilterPanel.ForeColor = Color.Black;
            this.gridView1.Appearance.FilterPanel.Options.UseBackColor = true;
            this.gridView1.Appearance.FilterPanel.Options.UseForeColor = true;
            this.gridView1.Appearance.FixedLine.BackColor = Color.FromArgb(0x75, 0x88, 0x7a);
            this.gridView1.Appearance.FixedLine.Options.UseBackColor = true;
            this.gridView1.Appearance.FocusedCell.BackColor = Color.White;
            this.gridView1.Appearance.FocusedCell.ForeColor = Color.Black;
            this.gridView1.Appearance.FocusedCell.Options.UseBackColor = true;
            this.gridView1.Appearance.FocusedCell.Options.UseForeColor = true;
            this.gridView1.Appearance.FocusedRow.BackColor = Color.FromArgb(0x81, 0xab, 0xb1);
            this.gridView1.Appearance.FocusedRow.ForeColor = Color.White;
            this.gridView1.Appearance.FocusedRow.Options.UseBackColor = true;
            this.gridView1.Appearance.FocusedRow.Options.UseForeColor = true;
            this.gridView1.Appearance.FooterPanel.BackColor = Color.FromArgb(0xca, 0xdd, 0xd0);
            this.gridView1.Appearance.FooterPanel.BorderColor = Color.FromArgb(0xca, 0xdd, 0xd0);
            this.gridView1.Appearance.FooterPanel.ForeColor = Color.Black;
            this.gridView1.Appearance.FooterPanel.Options.UseBackColor = true;
            this.gridView1.Appearance.FooterPanel.Options.UseBorderColor = true;
            this.gridView1.Appearance.FooterPanel.Options.UseForeColor = true;
            this.gridView1.Appearance.GroupButton.BackColor = Color.FromArgb(0xb2, 0xd1, 0xbc);
            this.gridView1.Appearance.GroupButton.BorderColor = Color.FromArgb(0xb2, 0xd1, 0xbc);
            this.gridView1.Appearance.GroupButton.Options.UseBackColor = true;
            this.gridView1.Appearance.GroupButton.Options.UseBorderColor = true;
            this.gridView1.Appearance.GroupFooter.BackColor = Color.FromArgb(0xd7, 0xea, 0xdd);
            this.gridView1.Appearance.GroupFooter.BorderColor = Color.FromArgb(0xd7, 0xea, 0xdd);
            this.gridView1.Appearance.GroupFooter.ForeColor = Color.Black;
            this.gridView1.Appearance.GroupFooter.Options.UseBackColor = true;
            this.gridView1.Appearance.GroupFooter.Options.UseBorderColor = true;
            this.gridView1.Appearance.GroupFooter.Options.UseForeColor = true;
            this.gridView1.Appearance.GroupPanel.BackColor = Color.FromArgb(0xf2, 0xf4, 0xec);
            this.gridView1.Appearance.GroupPanel.BackColor2 = Color.White;
            this.gridView1.Appearance.GroupPanel.ForeColor = Color.Black;
            this.gridView1.Appearance.GroupPanel.Options.UseBackColor = true;
            this.gridView1.Appearance.GroupPanel.Options.UseForeColor = true;
            this.gridView1.Appearance.GroupRow.BackColor = Color.FromArgb(0xd7, 0xea, 0xdd);
            this.gridView1.Appearance.GroupRow.BorderColor = Color.FromArgb(0xd7, 0xea, 0xdd);
            this.gridView1.Appearance.GroupRow.ForeColor = Color.Black;
            this.gridView1.Appearance.GroupRow.Options.UseBackColor = true;
            this.gridView1.Appearance.GroupRow.Options.UseBorderColor = true;
            this.gridView1.Appearance.GroupRow.Options.UseForeColor = true;
            this.gridView1.Appearance.HeaderPanel.BackColor = Color.FromArgb(0xd3, 0xe2, 0xd8);
            this.gridView1.Appearance.HeaderPanel.BorderColor = Color.FromArgb(0xd3, 0xe2, 0xd8);
            this.gridView1.Appearance.HeaderPanel.ForeColor = Color.Black;
            this.gridView1.Appearance.HeaderPanel.Options.UseBackColor = true;
            this.gridView1.Appearance.HeaderPanel.Options.UseBorderColor = true;
            this.gridView1.Appearance.HeaderPanel.Options.UseForeColor = true;
            this.gridView1.Appearance.HideSelectionRow.BackColor = Color.FromArgb(0xba, 0xd3, 0xd7);
            this.gridView1.Appearance.HideSelectionRow.ForeColor = Color.FromArgb(0x68, 130, 0x86);
            this.gridView1.Appearance.HideSelectionRow.Options.UseBackColor = true;
            this.gridView1.Appearance.HideSelectionRow.Options.UseForeColor = true;
            this.gridView1.Appearance.HorzLine.BackColor = Color.FromArgb(0xac, 0xc5, 180);
            this.gridView1.Appearance.HorzLine.BorderColor = Color.FromArgb(0x75, 0x88, 0x7a);
            this.gridView1.Appearance.HorzLine.Options.UseBackColor = true;
            this.gridView1.Appearance.HorzLine.Options.UseBorderColor = true;
            this.gridView1.Appearance.OddRow.BackColor = Color.FromArgb(0xf2, 0xf4, 0xec);
            this.gridView1.Appearance.OddRow.BorderColor = Color.FromArgb(0xf2, 0xf4, 0xec);
            this.gridView1.Appearance.OddRow.ForeColor = Color.Black;
            this.gridView1.Appearance.OddRow.Options.UseBackColor = true;
            this.gridView1.Appearance.OddRow.Options.UseBorderColor = true;
            this.gridView1.Appearance.OddRow.Options.UseForeColor = true;
            this.gridView1.Appearance.Preview.BackColor = Color.FromArgb(250, 250, 240);
            this.gridView1.Appearance.Preview.Font = new Font("Verdana", 7.5f);
            this.gridView1.Appearance.Preview.ForeColor = Color.FromArgb(0x68, 130, 0x86);
            this.gridView1.Appearance.Preview.Options.UseBackColor = true;
            this.gridView1.Appearance.Preview.Options.UseFont = true;
            this.gridView1.Appearance.Preview.Options.UseForeColor = true;
            this.gridView1.Appearance.Row.BackColor = Color.FromArgb(0xf2, 0xf4, 0xec);
            this.gridView1.Appearance.Row.ForeColor = Color.Black;
            this.gridView1.Appearance.Row.Options.UseBackColor = true;
            this.gridView1.Appearance.Row.Options.UseForeColor = true;
            this.gridView1.Appearance.RowSeparator.BackColor = Color.FromArgb(0xf2, 0xf4, 0xec);
            this.gridView1.Appearance.RowSeparator.BackColor2 = Color.White;
            this.gridView1.Appearance.RowSeparator.Options.UseBackColor = true;
            this.gridView1.Appearance.SelectedRow.BackColor = Color.FromArgb(0x9f, 0xc9, 0xcf);
            this.gridView1.Appearance.SelectedRow.ForeColor = Color.Black;
            this.gridView1.Appearance.SelectedRow.Options.UseBackColor = true;
            this.gridView1.Appearance.SelectedRow.Options.UseForeColor = true;
            this.gridView1.Appearance.TopNewRow.BackColor = Color.White;
            this.gridView1.Appearance.TopNewRow.Options.UseBackColor = true;
            this.gridView1.Appearance.VertLine.BackColor = Color.FromArgb(0xac, 0xc5, 180);
            this.gridView1.Appearance.VertLine.BorderColor = Color.FromArgb(0x75, 0x88, 0x7a);
            this.gridView1.Appearance.VertLine.Options.UseBackColor = true;
            this.gridView1.Appearance.VertLine.Options.UseBorderColor = true;
            this.gridView1.Columns.AddRange(new GridColumn[] { this.gridds_ma, this.gridds_ten, this.gridds_diachi, this.gridds_id, this.gridds_stt, this.gridds_dienthoai, this.gridds_sotk, this.gridds_masothue, this.gridds_nganhang, this.gridds_daidien });
            this.gridView1.GridControl = this.gridds;
            this.gridView1.Name = "gridView1";
            this.gridView1.OptionsView.AutoCalcPreviewLineCount = true;
            this.gridView1.OptionsView.EnableAppearanceEvenRow = true;
            this.gridView1.OptionsView.EnableAppearanceOddRow = true;
            this.gridView1.OptionsView.ShowAutoFilterRow = true;
            this.gridView1.OptionsView.ShowFooter = true;
            this.gridView1.CustomSummaryCalculate += new CustomSummaryEventHandler(this.gridView1_CustomSummaryCalculate);
            this.gridView1.FocusedRowChanged += new FocusedRowChangedEventHandler(this.gridView1_FocusedRowChanged);
            this.gridds_ma.Caption = "M\x00e3 số";
            this.gridds_ma.ColumnEdit = this.repositoryItemTextEdit1;
            this.gridds_ma.FieldName = "ma";
            this.gridds_ma.Name = "gridds_ma";
            this.gridds_ma.OptionsColumn.AllowEdit = false;
            this.gridds_ma.Summary.AddRange(new GridSummaryItem[] { new GridColumnSummaryItem(SummaryItemType.Count, "ma", "Số lượng={0:n0}") });
            this.gridds_ma.Visible = true;
            this.gridds_ma.VisibleIndex = 1;
            this.gridds_ma.Width = 0x5d;
            this.repositoryItemTextEdit1.AutoHeight = false;
            this.repositoryItemTextEdit1.Name = "repositoryItemTextEdit1";
            this.repositoryItemTextEdit1.ReadOnly = true;
            this.gridds_ten.Caption = "T\x00ean nh\x00e0 cung cấp";
            this.gridds_ten.ColumnEdit = this.repositoryItemTextEdit1;
            this.gridds_ten.FieldName = "ten";
            this.gridds_ten.Name = "gridds_ten";
            this.gridds_ten.OptionsColumn.AllowEdit = false;
            this.gridds_ten.OptionsColumn.FixedWidth = true;
            this.gridds_ten.Visible = true;
            this.gridds_ten.VisibleIndex = 2;
            this.gridds_ten.Width = 0xd7;
            this.gridds_diachi.Caption = "Địa chỉ";
            this.gridds_diachi.ColumnEdit = this.repositoryItemTextEdit1;
            this.gridds_diachi.FieldName = "diachi";
            this.gridds_diachi.Name = "gridds_diachi";
            this.gridds_diachi.OptionsColumn.AllowEdit = false;
            this.gridds_diachi.Visible = true;
            this.gridds_diachi.VisibleIndex = 3;
            this.gridds_diachi.Width = 0xbc;
            this.gridds_id.Caption = "id";
            this.gridds_id.FieldName = "id";
            this.gridds_id.Name = "gridds_id";
            this.gridds_stt.Caption = "STT";
            this.gridds_stt.ColumnEdit = this.repositoryItemTextEdit1;
            this.gridds_stt.FieldName = "stt";
            this.gridds_stt.Name = "gridds_stt";
            this.gridds_stt.OptionsColumn.AllowEdit = false;
            this.gridds_stt.Visible = true;
            this.gridds_stt.VisibleIndex = 0;
            this.gridds_stt.Width = 0x27;
            this.gridds_dienthoai.Caption = "Điện thoại";
            this.gridds_dienthoai.ColumnEdit = this.repositoryItemTextEdit1;
            this.gridds_dienthoai.FieldName = "dienthoai";
            this.gridds_dienthoai.Name = "gridds_dienthoai";
            this.gridds_dienthoai.OptionsColumn.AllowEdit = false;
            this.gridds_dienthoai.Visible = true;
            this.gridds_dienthoai.VisibleIndex = 4;
            this.gridds_dienthoai.Width = 0x59;
            this.gridds_sotk.Caption = "Số t\x00e0i khoản";
            this.gridds_sotk.FieldName = "sotk";
            this.gridds_sotk.Name = "gridds_sotk";
            this.gridds_sotk.Visible = true;
            this.gridds_sotk.VisibleIndex = 7;
            this.gridds_sotk.Width = 0x4e;
            this.gridds_masothue.Caption = "M\x00e3 số thuế";
            this.gridds_masothue.FieldName = "masothue";
            this.gridds_masothue.Name = "gridds_masothue";
            this.gridds_masothue.Visible = true;
            this.gridds_masothue.VisibleIndex = 6;
            this.gridds_masothue.Width = 0x4a;
            this.gridds_nganhang.Caption = "T\x00ean ng\x00e2n h\x00e0ng";
            this.gridds_nganhang.FieldName = "nganhang";
            this.gridds_nganhang.Name = "gridds_nganhang";
            this.gridds_nganhang.Visible = true;
            this.gridds_nganhang.VisibleIndex = 8;
            this.gridds_nganhang.Width = 0x74;
            this.gridds_daidien.Caption = "Người đại diện";
            this.gridds_daidien.FieldName = "daidien";
            this.gridds_daidien.Name = "gridds_daidien";
            this.gridds_daidien.Visible = true;
            this.gridds_daidien.VisibleIndex = 5;
            this.gridds_daidien.Width = 0x72;
            this.gridds.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Top;
            this.gridds.Location = new Point(0, 0x33);
            this.gridds.MainView = this.gridView1;
            this.gridds.Name = "gridds";
            this.gridds.RepositoryItems.AddRange(new RepositoryItem[] { this.repositoryItemTextEdit1 });
            this.gridds.Size = new Size(0x400, 0xf4);
            this.gridds.TabIndex = 0x11;
            this.gridds.ViewCollection.AddRange(new BaseView[] { this.gridView1 });
            this.btnboqua.Anchor = AnchorStyles.Bottom;
            this.btnboqua.Image = Resources.Reso.imgundo;// (Image)manager.GetObject("btnboqua.Image");
            this.btnboqua.Location = new Point(0x183, 0x185);
            this.btnboqua.Name = "btnboqua";
            this.btnboqua.Size = new Size(0x57, 0x17);
            this.btnboqua.TabIndex = 12;
            this.btnboqua.Text = " &Bỏ qua [F4]";
            this.btnboqua.Click += new EventHandler(this.btnboqua_Click);
            this.btnin.Anchor = AnchorStyles.Bottom;
            this.btnin.Image = Resources.Reso.imgprint;// (Image)manager.GetObject("btnin.Image");
            this.btnin.Location = new Point(0x22a, 0x185);
            this.btnin.Name = "btnin";
            this.btnin.Size = new Size(0x30, 0x17);
            this.btnin.TabIndex = 14;
            this.btnin.Text = " &In";
            this.btnin.Click += new EventHandler(this.btnin_Click);
            this.btnimport.Anchor = AnchorStyles.Bottom;
            this.btnimport.Image = Resources.Reso.imgimportexcel;// (Image)manager.GetObject("btnimport.Image");
            this.btnimport.Location = new Point(0x25c, 0x185);
            this.btnimport.Name = "btnimport";
            this.btnimport.Size = new Size(0x4b, 0x17);
            this.btnimport.TabIndex = 15;
            this.btnimport.Text = " &Chọn file";
            this.btnimport.Click += new EventHandler(this.btnimport_Click);
            this.label6.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            this.label6.Font = new Font("Tahoma", 10f);
            this.label6.Location = new Point(0xfd, 0x148);
            this.label6.Name = "label6";
            this.label6.Size = new Size(0x52, 0x13);
            this.label6.TabIndex = 2;
            this.label6.Text = "Địa chỉ:";
            this.label6.TextAlign = ContentAlignment.TopRight;
            this.txtdiachi.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom;
            this.txtdiachi.Location = new Point(0x14c, 0x147);
            this.txtdiachi.Name = "txtdiachi";
            this.txtdiachi.Size = new Size(0x1de, 20);
            this.txtdiachi.TabIndex = 4;
            this.txtdiachi.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            this.label8.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
            this.label8.Font = new Font("Tahoma", 10f);
            this.label8.Location = new Point(0x323, 0x148);
            this.label8.Name = "label8";
            this.label8.Size = new Size(0x63, 0x13);
            this.label8.TabIndex = 2;
            this.label8.Text = "Điện thoại:";
            this.label8.TextAlign = ContentAlignment.TopRight;
            this.txtdienthoai.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
            this.txtdienthoai.Location = new Point(0x387, 0x147);
            this.txtdienthoai.Name = "txtdienthoai";
            this.txtdienthoai.Size = new Size(0x73, 20);
            this.txtdienthoai.TabIndex = 5;
            this.txtdienthoai.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            this.label9.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            this.label9.Font = new Font("Tahoma", 10f);
            this.label9.Location = new Point(0xec, 0x162);
            this.label9.Name = "label9";
            this.label9.Size = new Size(0x63, 0x13);
            this.label9.TabIndex = 2;
            this.label9.Text = "Ng\x00e2n h\x00e0ng:";
            this.label9.TextAlign = ContentAlignment.TopRight;
            this.txtnganhang.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom;
            this.txtnganhang.Location = new Point(0x14c, 0x161);
            this.txtnganhang.Name = "txtnganhang";
            this.txtnganhang.Size = new Size(0x1de, 20);
            this.txtnganhang.TabIndex = 7;
            this.txtnganhang.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            this.label10.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
            this.label10.Font = new Font("Tahoma", 10f);
            this.label10.Location = new Point(0x330, 0x162);
            this.label10.Name = "label10";
            this.label10.Size = new Size(0x56, 0x13);
            this.label10.TabIndex = 2;
            this.label10.Text = "Số thứ tự:";
            this.label10.TextAlign = ContentAlignment.TopRight;
            this.txtsotk.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            this.txtsotk.Location = new Point(0x65, 0x161);
            this.txtsotk.Name = "txtsotk";
            this.txtsotk.Size = new Size(0x90, 20);
            this.txtsotk.TabIndex = 6;
            this.txtsotk.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.Controls.Add(this.txtstt);
            base.Controls.Add(this.txtma);
            base.Controls.Add(this.gridds);
            base.Controls.Add(this.btnketthuc);
            base.Controls.Add(this.btnimport);
            base.Controls.Add(this.btnin);
            base.Controls.Add(this.btnxoa);
            base.Controls.Add(this.btnboqua);
            base.Controls.Add(this.btnsua);
            base.Controls.Add(this.btnluu);
            base.Controls.Add(this.btnmoi);
            base.Controls.Add(this.txtten);
            base.Controls.Add(this.label3);
            base.Controls.Add(this.txtnganhang);
            base.Controls.Add(this.txtdienthoai);
            base.Controls.Add(this.txtdiachi);
            base.Controls.Add(this.label8);
            base.Controls.Add(this.label6);
            base.Controls.Add(this.txtmasothue);
            base.Controls.Add(this.txtsotk);
            base.Controls.Add(this.txtnguoidaidien);
            base.Controls.Add(this.label7);
            base.Controls.Add(this.label10);
            base.Controls.Add(this.label5);
            base.Controls.Add(this.label2);
            base.Controls.Add(this.label1);
            base.Controls.Add(this.label4);
            base.Controls.Add(this.label9);
            base.Name = "ucd_dmnhacungcap";
            base.Size = new Size(0x400, 0x19f);
            base.Load += new EventHandler(this.ucDMSanPham_Load);
            base.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            this.txtma.Properties.EndInit();
            this.txtten.Properties.EndInit();
            this.txtmasothue.Properties.EndInit();
            this.txtstt.Properties.EndInit();
            this.txtnguoidaidien.Properties.EndInit();
            this.gridView1.EndInit();
            this.repositoryItemTextEdit1.EndInit();
            this.gridds.EndInit();
            this.txtdiachi.Properties.EndInit();
            this.txtdienthoai.Properties.EndInit();
            this.txtnganhang.Properties.EndInit();
            this.txtsotk.Properties.EndInit();
            base.ResumeLayout(false);
        }

        private void txtten_Validated(object sender, EventArgs e)
        {
            try
            {
                this.txtten.Text = this.txtten.Text.Substring(0, 1).ToUpper() + this.txtten.Text.Substring(1);
            }
            catch
            {
            }
        }

        private void ucDMSanPham_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                SendKeys.Send("{Tab}");
            }
            else if (e.KeyCode == Keys.F2)
            {
                if (this.btnmoi.Enabled)
                {
                    this.btnmoi_Click(null, null);
                }
            }
            else if (e.KeyCode == Keys.F3)
            {
                if (this.btnsua.Enabled)
                {
                    this.btnsua_Click(null, null);
                }
            }
            else if (e.KeyCode == Keys.F4)
            {
                if (this.btnboqua.Enabled)
                {
                    this.btnboqua_Click(null, null);
                }
            }
            else if (e.KeyCode == Keys.F5)
            {
                if (this.btnluu.Enabled)
                {
                    this.btnluu_Click(null, null);
                }
            }
            else if (e.KeyCode == Keys.F7)
            {
                if (this.btnxoa.Enabled)
                {
                    this.btnxoa_Click(null, null);
                }
            }
            else if ((e.KeyCode == Keys.F12) && this.btnketthuc.Enabled)
            {
                this.btnketthuc_Click(null, null);
            }
        }

        private void ucDMSanPham_Load(object sender, EventArgs e)
        {
            this._dto = new dtoDDMNhaCungCap(this._condata);
            this._xuli = new General(this._condata);
            this.f_Loaddata_dmvp();
            this.btnboqua_Click(null, null);
            this.f_loadinfo_dmsanpham(0);
        }
    }
}

